On many platforms such as Linux® or Windows® by Microsoft Corp of Redmond, Wash. there are many libraries written in one language, typically C, that need to be used by programs written in another language, such as Perl, Python, C# by Microsoft Corp. or JAVA® by Sun Microsystems of Santa Clara, Calif. There are two solutions to this problem that are in use. Both of these solutions provide a compiled object, specific to the library being utilized, which sits in between the runtime language environment of the program requesting access to a library function and the library itself. One technique uses a system of templates from which code is generated that is compiled into a special library that can be loaded directly by a runtime language environment to access the functionality of the associated library. The generated code is fragile and must be reviewed by a programmer and often manually modified before compiling, which requires significant resources to be devoted to the maintenance of the special libraries.
The second technique is to write a new special library based on knowledge of the interfaces of a bound library such that the new special library can be loaded by a specific runtime language environment. This can require an even greater devotion of resources to generating the new special library. The new special libraries or ‘shim layer’ generated using both cases are commonly referred to as “language bindings,” a specific language binding, such as “Python bindings,” or just “bindings.”
There are also several libraries or programs that enable executing programs to make calls to libraries in other languages on the fly. However, these libraries and programs require the program making the call to provide function definitions and related calling conventions to the intermediate library that then calls the appropriate library or generates the code to call the appropriate library. This requires prior knowledge of the programmers of the program that makes the library call to hard code these types of calls. However, if the libraries are recompiled or altered in any way subsequently, then the calls can fail. Examples of these systems include DllImport in C# runtime by Microsoft Corp., the ‘libffi’ library by Red Hat, Inc. of Raleigh, N.C. and the ‘ctypes’ library for Python.
Microsoft's C# runtime provides a mechanism called “DllImport”, which makes use of code that functions analogously to libffi, and generates the calls on the fly from definitions you manually provide in your C# code. DllImport also has to specifically support the language from which it is importing such that it parses the declarations from the imported language directly.